#include<iostream>
#include<vector>
using namespace std;
int n;
int main()
{
	cin>>n;
	vector<int>a;
	a.resize(n+1);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	a[n]=0;
	int idx=0;
	int ans=0;
	while(idx<n){
		if(a[idx]<a[idx+1]){
			while(idx<n&&a[idx]<=a[idx+1]){
				idx++;
			}
			ans++;
			idx++;
		}
		else if(a[idx]==a[idx+1]) idx++;
		else {
			while(idx<n&&a[idx]>=a[idx+1]){
				idx++;
			}
			ans++;
			idx++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
